﻿using System;
using System.Linq;
using System.ComponentModel;
using System.Windows.Data;

using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Events;
using Microsoft.Practices.Prism.Regions;

using SearchModule.Models;
using SearchModule.Services;

namespace SearchModule.ViewModels
{
    /// <summary>
    /// ViewModel for SearchInputView.
    /// </summary>
    public class SearchInputViewModel : NotificationObject
    {
        private readonly IDataService _dataService;

        public SearchInputViewModel(IDataService dataService)
        {
            _dataService = dataService;

            SearchCommand = new DelegateCommand<string>(Search);
        }

        #region SearchCommand
        public DelegateCommand<string> SearchCommand { get; private set; }

        private void Search(string parameter)
        {
            if (!string.IsNullOrEmpty(parameter))
                _dataService.MakeSearchRequest(parameter);
        }
        #endregion
    }
}
